Deriving Backtracking Monad Transformers Functional Pearl

نویسنده

  • Ralf Hinze
چکیده

In a paper about pretty printing J. Hughes introdu ed two fundamental te hniques for deriving programs from their spe i ation, where a spe i ation onsists of a signature and properties that the operations of the signature are required to satisfy. Brie y, the rst te hnique, the term implementation, represents the operations by terms and works by de ning a mapping from operations to observations | this mapping an be seen as de ning a simple interpreter. The se ond, the ontext-passing implementation, represents operations as fun tions from their alling ontext to observations. We apply both te hniques to derive a ba ktra king monad transformer that adds ba ktra king to an arbitrary monad. In addition to the usual ba ktra king operations | failure and nondeterministi hoi e | the prolog ut and an operation for delimiting the e e t of a ut are supported.

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Eilenberg-Moore Monoids and Backtracking Monad Transformers

We develop an algebraic underpinning of backtracking monad transformers in the general setting of monoidal categories. As our main technical device, we introduce Eilenberg–Moore monoids, which combine monoids with algebras for strong monads. We show that Eilenberg–Moore monoids coincide with algebras for the list monad transformer (‘done right’) known from Haskell libraries. From this, we obtai...

متن کامل

Backtracking, Interleaving, and Terminating Monad Transformers

We design and implement a library for adding backtracking computations to any Haskell monad. Inspired by logic programming, our library provides, in addition to the operations required by the MonadPlus interface, constructs for fair disjunctions, fair conjunctions, conditionals, pruning, and an expressive top-level interface. Implementing these additional constructs is easy in models of backtra...

متن کامل

Monad Transformers for Backtracking Search

This paper extends Escardó and Oliva’s selection monad to the selection monad transformer, a general monadic framework for expressing backtracking search algorithms in Haskell. The use of the closely related continuation monad transformer for similar purposes is also discussed, including an implementation of a DPLL-like SAT solver with no explicit recursion. Continuing a line of work exploring ...

متن کامل

Prological Features in a Functional Setting Axioms and Implementation

The purpose of this paper is twofold. First, we show that Prological features can be smoothly integrated into a functional language like Haskell. The resultingìanguage', embedded Prolog, lacks some concepts such as logical variables but it inherits all of Haskell's strengths eg static polymorphic typing, higher order functions etc. Technically, the integration is achieved using monads and monad...

متن کامل

Reinventing Haskell Backtracking

Almost ten years ago, Ralf Hinze has written a functional pearl on how to derive backtracking functionality for the purely functional programming language Haskell. In these notes, we show how to arrive at the efficient, two-continuation based backtracking monad derived by Hinze starting from an intuitive inefficient implementation that we subsequently refine using well known program transformat...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2000